﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using Common.Constants;
using DataAccess;

namespace Business
{
    public class RoleBusiness
    {
        /// <summary>
        /// Gets the instance.
        /// </summary>
        /// <value>
        /// The instance.
        /// </value>
        public static RoleBusiness Instance
        {
            get;private set;
        }
        /// <summary>
        /// Initializes the <see cref="RoleBusiness" /> class.
        /// </summary>
        static RoleBusiness()
        {
            Instance = new RoleBusiness();
        }

        /// <summary>
        /// Creates the roles.
        /// </summary>
        /// <param name="arrayRoles">The array roles.</param>
        /// <returns></returns>
        public string CreateRoles(string arrayRoles)
        {
            if (String.IsNullOrEmpty(arrayRoles))
            {
                return null;
            }
            var roles = arrayRoles.Split('#');
            int count = 0;
            var textRoles = new StringBuilder("");
           
            foreach (var role in roles)
            {
                count++;
                switch (role)
                {
                    case "1":
                        textRoles.Append(OrgRole.Funder);
                        break;
                    case "2":
                        textRoles.Append(OrgRole.Lead);
                        break;
                    case "3":
                        textRoles.Append(OrgRole.Delivery);
                        break;
                    case "4":
                        textRoles.Append(OrgRole.Auditor);
                        break;
                }
                if (count != roles.Length)
                {
                    textRoles.Append(", ");
                }
            }
            return textRoles.ToString();
        } 
    }
}
